import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import axios from 'axios'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/fonts/iconfont.css'
// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 导入富文本样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 导入树形组件
import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', TreeTable)
Vue.use(ElementUI)
// 注册富文本编辑器
Vue.use(VueQuillEditor)
Vue.config.productionTip = false
// 配置请求的基准URL地址
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
}, err => {
  console.log(err)
})
// 重置时间格式的过滤器
Vue.filter('formDate', function (aa) {
  const data = new Date(aa)
  let y = data.getFullYear()
  let m = data.getMonth() + 1
  let d = data.getDate()
  let h = data.getHours()
  let mm = data.getMinutes()
  let s = data.getSeconds()
  const newDate = `${y}-${m}-${d} ${h}:${mm}:${s}`
  return newDate
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
